﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class paginas_Atividades : System.Web.UI.Page
{
    protected int ModelId
    {
        get
        {
            if (Request.QueryString["Id"] != null)
            {
                return Convert.ToInt32(Request.QueryString["Id"]);
            }
            else
            {
                return 0;
            }
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            var service = ServiceGerenciador.Model.FuncionarioServicos.FindAll();

            if (service.Length > 0)
                mvCrud.ActiveViewIndex = 0;//controle se existe registro e mostra a view
            else
                mvCrud.ActiveViewIndex = 1;

            gvCrud.DataSource = service;
            gvCrud.DataBind();
        }

    }
    protected void btnPesquisar_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(txtTermo.Text))
            return;

        gvCrud.DataSource = ServiceGerenciador.Model.FuncionarioServicos.Pesquisa(txtTermo.Text);
        gvCrud.DataBind();
    }
    protected void btnLimpar_Click(object sender, EventArgs e)
    {
        Response.Redirect("Atividades.aspx");
    }
    protected void btnNovo_Click(object sender, EventArgs e)
    {
        Response.Redirect("AtividadeNovo.aspx");
    }
}
